package com.lagou.controller;

import com.lagou.api.IUserService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * Created by wangq on 2021/9/22.
 */
@RestController
@RequestMapping(value = "/user")
public class UserController {
    @Reference
    IUserService iUserService;

    @GetMapping("/register/{email}/{password}/{code}")
    public Integer register(HttpServletResponse response, @PathVariable String email, @PathVariable String password, @PathVariable String code) {
        return iUserService.register(response, email, password, code);
    }

    @GetMapping("/isRegistered/{email}")
    public Boolean isRegistered(@PathVariable String email) {
        return iUserService.isRegistered(email);
    }

    @GetMapping("/login/{email}/{password}")
    public String login(HttpServletResponse response, @PathVariable String email, @PathVariable String password) {
        System.out.println(email + ">>>" + password);
        return iUserService.login(response, email, password);
    }

    @GetMapping("/info/{token}")
    public String info(@PathVariable String token) {
        return iUserService.info(token);
    }
}
